//
//  ViewController.swift
//  TaskConcurrencyDemo1
//
//  Created by 李煜 on 2024/5/21.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    func chuanAsyncFunc() async throws -> Int {
        try await withCheckedThrowingContinuation { continuation in
            DispatchQueue.global().async {
                do {
                    let result = try chuanFunc()
                    continuation.resume(returning: result)//返回结果
                } catch {
                    continuation.resume(throwing: error)//抛出异常
                }
            }
        }
    }


}

